<?php

namespace Home\Controller;
use Think\Controller;
// 指定允许其他域名访问  
header('Access-Control-Allow-Origin:*');  
// 响应类型  
header('Access-Control-Allow-Methods:*');  
// 响应头设置  
header('Access-Control-Allow-Headers:x-requested-with,content-type');  

class BaseinfoController extends Controller
{
    //网约车平台基本信息
     public function company()
     {
        if(!IS_POST)
        {
            company_msg(0,'非法操作');
        }
        
        //companyid,companyname,state,flag,updatetime
        $data=D('company_basic')
                ->field('identifier,address,businessscope,drivercontactaddress,economictype,regcapital,legal_person_name,legal_person_card,legal_person_mobile')
                ->select();
        if(empty($data))
        {
            company_msg('1','','暂无更多数据');
        }
        company_msg('1','',"成功",$data);
     }     

    //网约车平台公司营运规模信息
     public function companystat()
     {
        if(!IS_POST)
        {
            company_msg(0,'','非法操作');
        }
        
        $data=D('company_basic')
                ->field('vehiclenum,drivernum')
                ->select();
       
        if(empty($data))
        {
            company_msg('1','','暂无更多数据');
        }
        company_msg('1','',"成功",$data);
     }

     //网约车平台公司支付信息
     public function companypay()
     {
            if(!IS_POST)
            {
                company_msg(0,'','非法操作');
            }
            
            $data=D('company_basic')
                    ->field('payname,payid,paytype,payscope,preparebank')
                    ->select();
           
            if(empty($data))
            {
                company_msg('1','','暂无更多数据');
            }
            company_msg('1','',"成功",$data);
     }  

     //网约车平台公司服务机构
     public function companyserver()
     {
        if(!IS_POST)
        {
            company_msg(0,'','非法操作');
        }
        $data=D('service')
                ->field('address,servicename,serviceno,detailaddress,responsiblename,responsiblephone,managername,managerphone,mailaddress')
                ->select();
        if(empty($data))
        {
            company_msg('1','','暂无更多数据');
        }
        company_msg('1','',"成功",$data);
     }



    //图片上传
    public function uploadpic(){
        $currentdate='./Uploads/sign/';
        if(!is_dir($currentdate)){
            mkdir ($currentdate,0777,true);
        }
        $config = array(
            'maxSize'    =>    3145728,
            'rootPath'   =>    $currentdate,
            'savePath'   =>    '',
            'exts'       =>    array('jpg', 'gif', 'png', 'jpeg'),
            'saveName' => array('uniqid',''),
            'autoSub'    =>    false,
        );
        $upload = new \Think\Upload($config);
        $info = $upload->upload();
        if(!$info){
            datamsg(0,"没有上传成功");
        }else{
            $srcimg=array();
            $info_key=array_keys($info);
            foreach($info_key as $k=>$v){
                $srcimg[$k]=substr($currentdate.$info[$v]['savename'],1);
            }
            datamsg(1,"上传成功",$srcimg);
        }
    }

  
}
